import { CoolLocalStorage } from 'src/app/common/coolStorage/cool-local-storage';
import { ActivatedRoute } from '@angular/router';
import { Component, OnInit } from '@angular/core'
import { Location } from '@angular/common'
import { QuestionDetailService } from './service/question.service';

@Component({
    selector: 'app-estate-question-detail',
    templateUrl: './estate-question-detail.component.html',
    styleUrls: ['./estate-question-detail.component.scss']
})
export class EstateQuestionDetailComponent implements OnInit {
    public projectName: any;
    public loading: boolean=true;
    anwser = [1, 2, 3, 4, 5];
    public details:any;

    constructor(
        private location: Location,
        private routeInfo: ActivatedRoute,
        private service: QuestionDetailService,
        private cool: CoolLocalStorage,

    ) { }

    ngOnInit() {

        let id = this.routeInfo.snapshot.queryParams['project'];

        this.queryDetail(id);

    }

    onClickLeft() {
        this.location.back()
    }
    //queryDetail
    queryDetail(id) {

        let req = {
            "zone": this.cool.getItem('zone'),
            "question": id
        };

        this.service.queryDetail(req, res => {
            console.log(res);
            this.details = res.Result;
            this.projectName=res.Result.ProjectReference.Name
            this.loading = false;
        });
    }
}
